<?php
/**
 * application controller
 * @author bbqq <toughgamer@gmail.com>
 * @package com.blib.app
 * @copyright bbqq qstufie.com
 */
class Blib_App_Controller extends Blib_Class_Atomic
{
    /**
     * the view
     * @var Blib_App_View
     */
    protected $_view = null;


    /**
     * set the view object
     * @return this
     */
    public function setView(Blib_App_View $view)
    {
        $this->_view = $view;
        return $this;

    }// end setView


    /**
     * initialise function
     * overriden by children
     * for anything before the
     * main function
     */
    public function init()
    {
        Blib::_bp('Run init()');

    }// end init;

/*--------------------------[view related vars]--------------------------*/

    /**
     * set public key/val pair for rendering
     * @param str $key the key
     * @param mixed $val the value
     * @return self
     */
    public function set($key, $val)
    {
        $this->_view->set($key, $val);
        return $this;

    }// end set


    /**
     * get the vars out
     * @param str $key the key
     * @param mixed $defaul if not found, the default
     * @return mixed
     */
    public function get($key, $default = null)
    {
        return $this->_view->get($key, $default);

    }// end get


    /**
     * last function to run
     * overriden by children
     * the last thing after the
     * main function
     */
    public function finish()
    {
        // render
        $this->_view->render();
        Blib::_bp('Run finish()');

    }// end init;

}// end Blib_App_Controller
?>